package com.sample.action;


import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


import com.sample.action.form.ZhiduForm;

import com.sample.javabean.Zhidu;
import com.sample.util.Pager;

     /**
     * @author梁桂花
     *
     * 2018-10-24
     */
           public class ZhiduAction extends BaseAction {
    	 
      
    	   private final static Log log=LogFactory.getLog(ZhiduAction.class);
    	 	private Pager<Zhidu> pageList;
    	 	private Integer id;
    	 	private Zhidu zhidu=new Zhidu();
    	 	private ZhiduForm zhiduForm=new ZhiduForm();
    	 	
    	 	
    	 	/**
    	 	 * 公告信息录入界面
    	 	 * @return
    	 	 * @throws Exception
    	 	 */
    	 	public String inputZhidu()throws Exception{
    	 		
    	 		return "inputZhidu";
    	 	}
    	 	/**
    	 	 * 
    	 	 * @return
    	 	 * @throws Exception
    	 	 */
    	 	public String save()throws Exception{
    	 		try{
    	 			log.info("添加公告信息");
    	 			if(zhiduForm!=null){
    	 				Zhidu zhidu =new Zhidu();
    	 				 //将zhiduForm中的属性值一一对应zhidu的对应属性
    	 				zhidu.setNrong(zhiduForm.getNrong());
    	 				zhidu.setPerson(zhiduForm.getPerson());
    	 				zhidu.setPosttime(zhiduForm.getPosttime());
    	 				
    	 				
    	 			   //调用方法
    	 				zhidu.add();
    	 			}
    	 			return SUCCESS;
    	 		}catch (Exception e) {
    	 			e.printStackTrace();
    	 			
    	 		}
    	 		return "inputZhidu";
    	 	}
    	 	
    	 	public String list()throws Exception{
    	 		Zhidu zhiduModel =new Zhidu();
    	 		pageList =zhiduModel.list(page,size,zhiduForm);
    	 		return "listZhidu";
    	 	}
    	 	public String del()throws Exception{
    	 		try{
    	 			if(zhiduForm!=null){
    	 				zhidu.setId(id);
    	 				zhidu.delZhidu();	
    	 			}
    	 			return SUCCESS;
    	 		}catch (Exception e) {
    	 			e.printStackTrace();
    	 			throw e;
    	 		}	
    	 	}
    	 	public String editZhidu()throws Exception{
    	 		try{
    	 			zhidu.setId(id);
    	 			zhidu.load();
    	 			return "editZhidu";
    	 		}catch (Exception e) {
    	 			e.printStackTrace();
    	 			throw e;
    	 		}	
    	 	}
    	 	/**
    	 	 * 
    	 	 * @return
    	 	 * @throws Exception
    	 	 */
    	 	public String edit()throws Exception{
    	 		log.info("sss");
    	 		try{
    	 			
    	 			if(zhiduForm!=null){
    	 				zhidu.setId(zhiduForm.getId());	
    	 				
    	 				zhidu.setNrong(zhiduForm.getNrong());
    	 			
    	 				zhidu.setPerson(zhiduForm.getPerson());
    	 				
    	 				zhidu.setPosttime(zhiduForm.getPosttime());
    	 			
    	 				
    	 				
    	 				zhidu.editZhidu();	
    	 			}
    	 			log.info("sss");
    	 			return SUCCESS;
    	 		}catch (Exception e) {
    	 			e.printStackTrace();
    	 			throw e;
    	 		}	
    	 	}
			public Pager<Zhidu> getPageList() {
				return pageList;
			}
			public void setPageList(Pager<Zhidu> pageList) {
				this.pageList = pageList;
			}
			public Integer getId() {
				return id;
			}
			public void setId(Integer id) {
				this.id = id;
			}
			public Zhidu getZhidu() {
				return zhidu;
			}
			public void setZhidu(Zhidu zhidu) {
				this.zhidu = zhidu;
			}
			public ZhiduForm getZhiduForm() {
				return zhiduForm;
			}
			public void setZhiduForm(ZhiduForm zhiduForm) {
				this.zhiduForm = zhiduForm;
			}
			public static Log getLog() {
				return log;
			}
			
    	
}
